package model;
import java.util.Vector;

/**
 * The Material class is a component without structure.
 * 
 * @author hfi411pi
 *
 */
public class Material extends ComponentCommon {

	private static final String UnstructuredMaterialMessage = "Materialien haben kein Struktur!";
	
	/**
	 * Factory method for creating Materials.
	 * @param name is the name of the Material.
	 * @param price is the Price of the Material.
	 * @return the created Material.
	 */
	public static Material create(final String name, final int price) {
		return new Material(name,price);
	}
	
	/**
	 * Material constructor.
	 * @param name is the name of the Material.
	 * @param price is the price of the Material.
	 */
	public Material(final String name, final int price) {
		super(name,price);
	}
	
	@Override
	public void addPart(final ComponentCommon part, final int amount) throws Exception {
		throw new Exception(UnstructuredMaterialMessage);
	}
	
	/** Provides false.
	 *  Material don't contain components.
	 * @return false
	 */
	@Override
	public boolean containsTransitive(final ComponentCommon component) {
		return false;
	}
	
	/** Provides an empty Vector.
	 * Materials don't have any direct parts.
	 * @return an empty Vector.
	 */
	@Override
	public Vector<QuantifiedComponent> getDirectParts() {
		return new Vector<QuantifiedComponent>();
	}
	
	/** Provides the amount of materials that are required for this component.
	 * @return 1
	 */
	@Override
	public int getNumberOfMaterials() {
		return 1;
	}
	
	/** Provides the price of this component.
	 * @return the price of this material.
	 */
	@Override
	public int calculateNewOverallPriceTransitive() {
		return 0;
	}
	
	/** Provides a MaterialList with this material.
	 * @return a MaterialList containing this material.
	 */
	@Override
	public MaterialList getMaterialList() {
		return this.calculateNewMaterialList();
	}

	@Override
	public MaterialList calculateNewMaterialList() {
		final MaterialList result = MaterialList.create();
		result.add(QuantifiedComponent.createQuantifiedComponent(1, this));
		return result;
	}
}